package scau.jump.securitytrace.client.addresslistener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class AddressListenerController implements ActionListener {
	
	private AddressActionListener addressActionListener;
	
	public AddressListenerController(AddressActionListener addressActionListener) {
		this.addressActionListener = addressActionListener;
	}
	
	@Override
	public void actionPerformed(ActionEvent event) {
		String methodName = event.getActionCommand();
		try {
			Method excuteMethod = addressActionListener.getClass().getDeclaredMethod(methodName, new Class<?>[]{});
			excuteMethod.invoke(addressActionListener, new Object[]{});
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}
	}

}
